import request from '@/utils/request'

/** 获取已经分层级的菜单列表 */
export function GetDictionaryitem() {
  return request({
    url: '/Dictionary/GetDictionary',
    method: 'get'
  })
}


/** 获取全部的未分层级的字典列表 */
export function GetDictionaryall() {
  return request({
    url: '/Dictionary/GetAllDictionary',
    method: 'get'
  })
}


export function addDic(data) {
  return request({
    url: '/Dictionary/addDic',
    method: 'post',
    data
  })
}

export function updateDic(data) {
  return request({
    url: `/Dictionary/updateDic`,
    method: 'post',
    data
  })
}

/** 删除字典 */
export function deleteDic(id) {
  return request({
    url: '/Dictionary/DeleteDic?id=' + id,
    method: 'get'
  })
}

export function GetDictionaryByPCode(code) {
  return request({
    url: '/Dictionary/GetDictionaryByPCode?code=' + code,
    method: 'get'
  })
}

// 检查字典code是否重复
export function existCode(code) {
  return request({
    url: '/Dictionary/existCode?code=' + code,
    method: 'get'
  })
}

/**
 * 根据code获取对应的字典，用于select展示
 * @param {*} code 
 */
export function GetSelectDicByCode(code) {
  return request({
    url: '/Dictionary/GetSelectDicByCode?code=' + code,
    method: 'get'
  })
}